//mutations是store状态的更新唯一方式
import * as types from './mutation-types'

const mutations = {
    //设置用户
    [types.SET_USER](state,user){
        state.user = user
        window.sessionStorage.setItem('user',JSON.stringify(user))
    },
    [types.SET_AUTHORIZATION](state,token){
        state.authorization = token
        if(token === ''){ //如果是空,则清除
            localStorage.removeItem('Authorization')
        }else{//不是空,则设置
            localStorage.setItem('Authorization',token)
        }
    }
}

export default mutations